﻿namespace Serenity.ComponentModel;

/// <summary>
/// Base class for dynamic script attributes.
/// Dynamic scripts contain dynamic data, but they are not parameterized.
/// </summary>
/// <seealso cref="Attribute" />
/// <remarks>
/// Initializes a new instance of the <see cref="DynamicScriptAttribute"/> class.
/// </remarks>
/// <param name="key">The key.</param>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public abstract class DynamicScriptAttribute(string key) : Attribute
{

    /// <summary>
    /// Gets the key.
    /// </summary>
    /// <value>
    /// The key.
    /// </value>
    public string Key { get; private set; } = key;

    /// <summary>
    /// Gets or sets the duration of the caching.
    /// </summary>
    /// <value>
    /// The duration of the caching.
    /// </value>
    public int CacheDuration { get; set; }

    /// <summary>
    /// Gets or sets the cache group key. 
    /// Group keys are used to invalidate a group of items.
    /// </summary>
    /// <value>
    /// The cache group key.
    /// </value>
    public string? CacheGroupKey { get; set; }
}